import { getModule, Module, Mutation, VuexModule } from 'vuex-module-decorators';
import store from '../index';

export interface ICustom {
    menuCollapse: boolean;
}

@Module({ dynamic: true, name: 'custom', namespaced: true, store })
class CustomStore extends VuexModule {
    // 默认不折叠导航栏
    public menuCollapse: boolean = false;
    // OIS状态
    public OISStatus: string = '1';

    /**
     * 修改导航栏折叠状态
     * @param bl
     */
    @Mutation
    updateMenuCollapse(bl?: boolean): void {
        if (bl === true || bl === false) {
            this.menuCollapse = bl;
        } else {
            this.menuCollapse = !this.menuCollapse;
        }
    }
    /**
     * 获取导航折叠状态
     */
    get getMenuCollapse(): boolean {
        return this.menuCollapse;
    }

    /**
     * 修改OIS状态
     * 0失败 1成功 2正在同步 3同步失败 4未同步
     */
    @Mutation
    updateOISStatus(val): void {
        if (val === this.OISStatus) {
            return
        }
        this.OISStatus = val;
    }

    /**
     * 获取OIS状态
     */
    get getOISStatus(): string {
        return this.OISStatus;
    }
}

export const CustomModule = getModule(CustomStore);
